﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/EditMaster.Master" AutoEventWireup="true"
    CodeBehind="EditBugType.aspx.cs" Inherits="BugSysSolution.DataManagement.EditBugType1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../Javascript/CheckForm.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
        <table id="tab1" class="tab">
            <tr>
                <td style="text-align: right" colspan="3">
                    <input type="button" id="btnAdd" class="btn" value="AddType" onclick="SaveInfo(null, 'add');" />
                </td>
            </tr>
            <tr>
                <td>ID
                </td>
                <td>Value
                </td>
                <td>操作
                </td>
            </tr>
            <asp:Repeater ID="rep" runat="server">
                <HeaderTemplate>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <%# Eval("TypeId") %>
                        </td>
                        <td>
                            <%# Eval("TypeText") %>
                        </td>
                        <td>
                            <a tagid='<%# Eval("TypeId") %>' tagval='<%# Eval("TypeText") %>' onclick="SaveInfo(this,'edit');"
                                href="#">Edit</a>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
    </div>
    <div id="showinfo1" style="display: none">
        <table id="tab2">
            <tr>
                <td>ID：
                </td>
                <td>
                    <input type="text" id="typeid" readonly="readonly" />
                </td>
            </tr>
            <tr>
                <td>Value：
                </td>
                <td>
                    <input type="text" id="typeval" />
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        $(function () {
            $("#showinfo1").dialog({
                autoOpen: false,
                bgiframe: true,
                resizable: true,
                width: 400,
                height: 250,
                modal: true,
                title: 'Save Type',
                buttons: {
                    '保存': function () {
                        var parm = {
                            tag: type,
                            id: $("#typeid").val(),
                            val: $("#typeval").val()
                        };
                        SendAjax("post", requestUrl, parm, "", function (data) {
                            if (data == "Success") {
                                window.location.reload();
                            }
                        })
                    },
                    '删除': function () {
                        DelInfo();
                    }
                }
            });
        })

        var requestUrl = "../RequestAjaxPage/BugTypeAjaxPage.aspx";
        var type = "";
        function SaveInfo(obj, tag) {
            if (obj == null) {
                $("#typeid").val("不需要填写!");
            }
            else {
                $("#typeid").val($(obj).attr("tagid"));
            }
            $("#typeval").val($(obj).attr("tagval"));

            type = tag;

            $("#showinfo1").dialog("open");
        }

        function DelInfo() {
            if (CheckForm.isNum($("#typeid").val()) == false) {
                $("#showinfo1").dialog("close");
                return;
            }
            if (confirminfo("确定是否要删除?")) {
                var parm = {
                    tag: 'del',
                    id: $("#typeid").val(),
                    val: $("#typeval").val()
                };
                SendAjax("post", requestUrl, parm, "", function (data) {
                    if (data == "Success") {
                        window.location.reload();
                    }
                });
                $("#showinfo1").dialog("close");
            }
        }
    </script>
</asp:Content>
